﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using YJKAreaCutter.Properties;

namespace YJKAreaCutter
{
	public partial class GifForm : System.Windows.Forms.Form
	{
		public GifForm()
		{
			this.InitializeComponent();
			base.Opacity = 1.0;
			this.ActivateWindow();
		}

		public string Tip
		{
			set
			{
				this.lblTip.Text = value;
			}
		}

		private void RefreshTopMost()
		{
			if (base.InvokeRequired)
			{
				GifForm.m_dgtRefreshTopMost method = new GifForm.m_dgtRefreshTopMost(this.RefreshTopMost);
				base.Invoke(method);
				return;
			}
			base.Activate();
		}

		private void RefreshThreadFunction()
		{
			for (;;)
			{
				this.m_nRefreshCont++;
				this.RefreshTopMost();
				Thread.Sleep(5000 * this.m_nRefreshCont);
			}
		}

		private void ActivateWindow()
		{
			this.m_Refreshthread = new Thread(new ThreadStart(this.RefreshThreadFunction));
			this.m_Refreshthread.IsBackground = true;
			this.m_Refreshthread.Start();
		}

		public void CloseThread()
		{
			if (this.m_Refreshthread != null)
			{
				this.m_Refreshthread.Abort();
				this.m_Refreshthread = null;
			}
		}

		private void GifForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			this.m_nRefreshCont = 0;
		}

		private Thread m_Refreshthread;

		private int m_nRefreshCont;

		private delegate void m_dgtRefreshTopMost();
	}
}
